import { Component, OnInit, ViewChild } from '@angular/core';
import { SortDirective } from '@iux/live';
import { Demo5Service } from './demo5.service';
import { pipe } from 'rxjs';
import { startWith, switchMap, filter } from 'rxjs/operators';

@Component({
  selector: 'app-demo5',
  templateUrl: './demo5.component.html',
  styles: [],
})
export class Demo5Component implements OnInit {
  data;
  constructor(private dataService: Demo5Service) {}

  ngOnInit() {
    this.initAsyncData();
  }

  initAsyncData() {
    this.sortData({});
  }

  sortData(source) {
    this.dataService.getUsersBySort(source.direction).subscribe(res => {
      this.data = res.slice(0, 10);
    });
  }
}
